home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / vbcc-wos-src / vlink / elf32.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  5KB  |  157 lines

  1. /* $VER: vlink elf32.h V0.3b (25.04.98)
  2.  *
  3.  * This file is part of vlink, a portable linker for multiple
  4.  * object formats.
  5.  * Copyright (c) 1997-99  Frank Wille
  6.  *
  7.  * vlink is freeware and part of the portable and retargetable ANSI C
  8.  * compiler vbcc, copyright (c) 1995-99 by Volker Barthelmann.
  9.  * vlink may be freely redistributed as long as no modifications are
  10.  * made and nothing is charged for it. Non-commercial usage is allowed
  11.  * without any restrictions.
  12.  * EVERY PRODUCT OR PROGRAM DERIVED DIRECTLY FROM MY SOURCE MAY NOT BE
  13.  * SOLD COMMERCIALLY WITHOUT PERMISSION FROM THE AUTHOR.
  14.  *
  15.  *
  16.  * v0.3b (25.04.98) phx
  17.  *       Included ELF32_ST_xxx and ELF32_R_xxx from elfcommon.h.
  18.  * v0.3  (13.04.98) phx
  19.  *       Included vlink-specific list and node definitions.
  20.  * v0.0  (21.03.98) phx
  21.  *       File created.
  22.  */
  23.  
  24.  
  25. #include "elfcommon.h"
  26.  
  27.  
  28. struct Elf32_Ehdr {
  29.   unsigned char    e_ident[EI_NIDENT];    /* ELF "magic number" */
  30.   unsigned char    e_type[2];          /* Identifies object file type */
  31.   unsigned char    e_machine[2];       /* Specifies required architecture */
  32.   unsigned char    e_version[4];       /* Identifies object file version */
  33.   unsigned char    e_entry[4];         /* Entry point virtual address */
  34.   unsigned char    e_phoff[4];         /* Program header table file offset */
  35.   unsigned char    e_shoff[4];         /* Section header table file offset */
  36.   unsigned char    e_flags[4];         /* Processor-specific flags */
  37.   unsigned char    e_ehsize[2];        /* ELF header size in bytes */
  38.   unsigned char    e_phentsize[2];     /* Program header table entry size */
  39.   unsigned char    e_phnum[2];         /* Program header table entry count */
  40.   unsigned char    e_shentsize[2];     /* Section header table entry size */
  41.   unsigned char    e_shnum[2];         /* Section header table entry count */
  42.   unsigned char    e_shstrndx[2];      /* Section header string table index */
  43. };
  44.  
  45. struct Elf32_Phdr {
  46.   unsigned char p_type[4];          /* Identifies program segment type */
  47.   unsigned char p_offset[4];        /* Segment file offset */
  48.   unsigned char p_vaddr[4];         /* Segment virtual address */
  49.   unsigned char p_paddr[4];         /* Segment physical address */
  50.   unsigned char p_filesz[4];        /* Segment size in file */
  51.   unsigned char p_memsz[4];         /* Segment size in memory */
  52.   unsigned char p_flags[4];         /* Segment flags */
  53.   unsigned char p_align[4];         /* Segment alignment, file & memory */
  54. };
  55.  
  56. struct Elf32_Shdr {
  57.   unsigned char sh_name[4];         /* Section name, index in string tbl */
  58.   unsigned char sh_type[4];         /* Type of section */
  59.   unsigned char sh_flags[4];        /* Miscellaneous section attributes */
  60.   unsigned char sh_addr[4];         /* Section virtual addr at execution */
  61.   unsigned char sh_offset[4];       /* Section file offset */
  62.   unsigned char sh_size[4];         /* Size of section in bytes */
  63.   unsigned char sh_link[4];         /* Index of another section */
  64.   unsigned char sh_info[4];         /* Additional section information */
  65.   unsigned char sh_addralign[4];    /* Section alignment */
  66.   unsigned char sh_entsize[4];      /* Entry size if section holds table */
  67. };
  68.  
  69. struct Elf32_Sym {
  70.   unsigned char st_name[4];         /* Symbol name, index in string tbl */
  71.   unsigned char st_value[4];        /* Value of the symbol */
  72.   unsigned char st_size[4];         /* Associated symbol size */
  73.   unsigned char st_info[1];         /* Type and binding attributes */
  74.   unsigned char st_other[1];        /* No defined meaning, 0 */
  75.   unsigned char st_shndx[2];        /* Associated section index */
  76. };
  77. /* st_info */
  78. #define ELF32_ST_BIND(i) ((i)>>4)
  79. #define ELF32_ST_TYPE(i) ((i)&0xf)
  80. #define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
  81.  
  82. struct Elf32_Note {
  83.   unsigned char namesz[4];          /* Size of entry's owner string */
  84.   unsigned char descsz[4];          /* Size of the note descriptor */
  85.   unsigned char type[4];            /* Interpretation of the descriptor */
  86.   char          name[1];            /* Start of the name+desc data */
  87. };
  88.  
  89. struct Elf32_Rel {
  90.   unsigned char r_offset[4];    /* Location at which to apply the action */
  91.   unsigned char r_info[4];      /* index and type of relocation */
  92. };
  93.  
  94. struct Elf32_Rela {
  95.   unsigned char r_offset[4];    /* Location at which to apply the action */
  96.   unsigned char r_info[4];      /* index and type of relocation */
  97.   unsigned char r_addend[4];    /* Constant addend used to compute value */
  98. };
  99.  
  100. /* r_info */
  101. #define ELF32_R_SYM(i) ((i)>>8)
  102. #define ELF32_R_TYPE(i) ((unsigned char)(i))
  103. #define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t))
  104.  
  105. struct Elf32_Dyn {
  106.   unsigned char d_tag[4];           /* entry tag value */
  107.   union {
  108.     unsigned char d_val[4];
  109.     unsigned char d_ptr[4];
  110.   } d_un;
  111. };
  112.  
  113.  
  114. /* vlink specific - used to generate ELF32 output files */
  115.  
  116. #define STRHTABSIZE 0x10000
  117. #define SHSTRHTABSIZE 0x100
  118.  
  119. struct StrTabNode {
  120.   struct node n;
  121.   struct StrTabNode *hashchain;
  122.   char *str;
  123.   uint32 index;
  124. };
  125.  
  126. struct StrTabList {
  127.   struct list l;
  128.   struct StrTabNode **hashtab;
  129.   unsigned long htabsize;
  130.   uint32 nextindex;
  131. };
  132.  
  133. struct SymbolNode {
  134.   struct node n;
  135.   struct SymbolNode *hashchain;
  136.   char *name;
  137.   struct Elf32_Sym s;
  138.   uint32 index;
  139. };
  140.  
  141. struct SymTabList {
  142.   struct list l;
  143.   struct SymbolNode **hashtab;
  144.   uint32 nextindex;
  145.   uint32 global_index;
  146. };
  147.  
  148. struct ShdrNode {
  149.   struct node n;
  150.   struct Elf32_Shdr s;
  151. };
  152.  
  153. struct RelaNode {
  154.   struct node n;
  155.   struct Elf32_Rela r;
  156. };
  157.